package com.android.equipment.utils;

import android.graphics.Bitmap;

import java.util.Collection;
import java.util.List;

/**
 * 判读是否为null
 */

public class IsNull {

    private static boolean isNullOrEmpty(String s) {
        return (s != null) && (!"null".equals(s)) && (s.length() > 0);
    }

    private static <T> boolean isNullOrEmpty(Collection<T> c) {
        return (c != null) && (c.size() > 0);
    }

    public static <T> boolean isNullOrEmpty(T[] arr) {
        return (arr != null) && (arr.length > 0);
    }

    private static boolean isNullOrEmpty(Bitmap bmp) {
        return (bmp != null) && !(bmp.isRecycled());
    }

    public static <T> boolean isNullOrEmpty(T t) {
        if (t instanceof Bitmap) {
            return isNullOrEmpty((Bitmap) t);
        } else if (t instanceof String) {
            return isNullOrEmpty((String) t);
        } else if (t instanceof Collection) {
            return isNullOrEmpty((Collection<?>) t);
        } else {
            return t != null;
        }
    }
    public static boolean isNotEmpty(List list){
        if(list != null && list.size() > 0){
            return true;
        }
        return false;
    }

}
